package com.shark.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @ClassName OutOfMemoryErrorDemo
 * @Description TODO
 * @Author 东北彭于晏
 * @Date 2024/10/9  17:09
 * @Version 1.0
 **/
public class OutOfMemoryErrorDemo {
    public static void main(String[] args) {
        AtomicLong atomicLong = new AtomicLong(0);

        List<byte[]> list = new ArrayList<>();


        while (true) {
            list.add(new byte[5 * 1024 * 1024]);
            System.out.println("分配次数：" + (atomicLong.getAndIncrement()));
        }
    }
}
